package com.example.mobile2121606109ycg0328;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private EditText edtTxtMainNumA;
    private EditText edtTxtMainNumB;
    private Button btnMainResult;
    private TextView tvMainResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainResult.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    int a =  Integer.valueOf(edtTxtMainNumA.getText().toString());
                    int b = Integer.valueOf(edtTxtMainNumB.getText().toString());

                    int c = a + b;

                    tvMainResult.setText("结果：" + String.valueOf(c));
                }catch (){

                }
            }
        });
    }

    private void initView() {
        edtTxtMainNumA = (EditText) findViewById(R.id.edtTxtMainNumA);
        edtTxtMainNumB = (EditText) findViewById(R.id.edtTxtMainNumB);
        btnMainResult = (Button) findViewById(R.id.btnMainResult);
        tvMainResult = (TextView) findViewById(R.id.tvMainResult);
    }
}